package sad_G211;

import weka.core.*;
//import weka.classifiers.*;
import weka.classifiers.lazy.IBk;
import weka.classifiers.meta.*;
//import weka.classifiers.trees.*;

//import java.io.*;

/**
 * A little example for optimizing J48's confidence parameter with 
 * CVPArameterSelection meta-classifier.
 * The class expects a dataset as first parameter, class attribute is
 * assumed to be the last attribute.
 *
 * @author FracPete (fracpete at waikato dot ac dot nz)
 */
public class CVParam {
	public static void clasificar(Instances data) throws Exception{
   //public static void main(String[] args) throws Exception {
      // load data
      //BufferedReader reader = new BufferedReader(new FileReader(args[0]));
      //Instances data = new Instances(reader);
      //reader.close();
      //data.setClassIndex(data.numAttributes() - 1);

      // setup classifier
      CVParameterSelection ps = new CVParameterSelection();
      ps.setClassifier(new IBk(10));//Ponemos el modelo que queremos utilizar kNN, vamos a probar hasta k=10
      ps.setNumFolds(10);  // using 10-fold CV
      ps.addCVParameter("K 1 10 10");

      // build and output best options
      ps.buildClassifier(data);
      System.out.println("Resultados con CVParam");
	  System.out.println("----------------------------------------------------------");
      System.out.println(Utils.joinOptions(ps.getBestClassifierOptions()));
      System.out.println("----------------------------------------------------------");
	  System.out.println("----------------------------------------------------------");
   }
}